#include<bits/stdc++.h>
using namespace std;

long long getDescentPeriods(vector<int>& prices)
{
    long long ans = 0, cnt = 1;
    for(int i = 1;i < prices.size();i++)
    {
        if(prices[i] + 1 == prices[i-1])
            cnt++;
        else
        {
            ans += cnt*(cnt+1)/2;
            cnt = 1;
        }
    }
    return ans + cnt*(cnt+1)/2;
}

int main()
{
	vector<int> prices;
	int x;
	while(cin>>x)
		prices.push_back(x);
	
	long long ans = getDescentPeriods(prices);
	cout<<ans; 
	return 0;
}

